<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:requestEncoding value="utf-8" />
<header>
	<div class="row">
		<!-- logo, search, topMenu -->
		<div class="col-xs-2">
			<a href="/Reservation/main/index.res"><img src="../img/logo.gif"
				alt="mainLogo" /></a>
		</div>
		<div class="col-xs-8">
			<!--
			<form class="" role="form">
				<input class="form-control input" type="text" name="searchString"
					placeholder="검색어를 입력해주세요." />
				<button type="button" class="btn btn-primary" id="searchBtn">통합검색</button>
			</form>
		-->
		</div>
		<div class="col-xs-2" style="text-align: right;">
			<ul class="list-inline">
				<c:if test="${ empty sessionScope.isLogin }">
					<li><a href="/Reservation/join/join.res">회원가입</a></li>
					<li><a href="/Reservation/myPage/find.res">아이디/비밀번호 찾기</a></li>
				</c:if>
				<li><a href="#">고객센터</a></li>
			</ul>
		</div>
	</div>

	<!-- mene nav bar -->
	<nav class="navbar navbar-default" role="navigation">
		<!-- normal menubar -->
		<div class="nav navbar-left">
			<form id="goList">
				<input type="hidden" id="listType" name="type" value="" />
				<ul class="nav navbar-nav">
					<li ${ empty param.body ? "class='active'" : "" }><a
						href="/Reservation/main/index.res">홈</a></li>
					<li ${ (param.body eq "/main/guide.jsp") ? "class='active'" : "" }><a
						href="/Reservation/main/guide.res">이용안내</a></li>
					<li ${ param.type eq "gym" ? "class='active'" : "" }><a
						id="gym" href="#">체육시설</a></li>
					<li ${ param.type eq "pub" ? "class='active'" : "" }><a
						id="pub" href="#">시설대관</a></li>
					<li><a href="#" id="showqr">빠른예약</a></li>
				</ul>
			</form>
		</div>

		<!-- before login -->
		<c:if test="${ empty sessionScope.isLogin }">
			<div id="loginDiv" class="nav navbar-right">
				<form class="navbar-form" role="login">
					<div class="form-group">
						<input type="text" name="uid" id="uid" class="form-control input"
							placeholder="아이디"> <input type="password" name="passwd"
							id="passwd" class="form-control input" placeholder="비밀번호">
					</div>
					<button type="button" id="loginBtn" class="btn btn-default">로그인</button>
				</form>
			</div>
		</c:if>

		<!-- after login -->
		<c:if test="${ not empty sessionScope.isLogin }">
			<div id="logoutDiv" class="nav navbar-right">
				<ul class="nav navbar-nav">
					<li><p id="loginUser" class="navbar-text">${ member.name }님
							환영합니다.</p></li>
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown"> 마이페이지<b class="caret"></b>
					</a>
						<ul class="dropdown-menu">
							<li><a href="/Reservation/myPage/editMemberInfo.res">회원정보수정</a></li>
							<li><a href="/Reservation/myPage/reservStatusList.res">마이페이지</a></li>
						</ul></li>
					<li>
						<button type="button" id="logoutBtn"
							class="btn btn-default navbar-btn">로그아웃</button>
					</li>
				</ul>
			</div>
		</c:if>
	</nav>
</header>
<!-- login&logout -->
<script>
	$("#loginBtn").click(function() {
		$.ajax({
			url : "/Reservation/logProcess/login.res",
			type : "post",
			data : {
				uid : $("#uid").val(),
				passwd : $("#passwd").val()
			},
			success : function(result) {
				if (result == 0) {
					alert("존재하지 않는 아이디이거나 비밀번호가 맞지않습니다.");
				} else if (result == 1) {
					alert("로그인되었습니다.");
					location.reload();
				} else {
					alert("알수없는 오류!!");
				}
			}
		});
		0
	})
	$("#logoutBtn").click(function() {
		$.ajax({
			url : "/Reservation/logProcess/logout.res",
			success : function() {
				alert("로그아웃되었습니다.");
				location.reload();
			}
		});
	});
	$("#gym").click(
			function() {
				$("#listType").val("gym");
				$("#goList").attr("method", "post").attr("action",
						"/Reservation/reserv/list.res").submit();
			});
	$("#pub").click(
			function() {
				$("#listType").val("pub");
				$("#goList").attr("method", "post").attr("action",
						"/Reservation/reserv/list.res").submit();
	});
</script>